package com.gs.SynAntiWandering.dialog;

import android.content.Context;
import android.widget.RadioGroup;

import androidx.annotation.NonNull;

import com.gs.SynAntiWandering.R;
import com.gs.SynAntiWandering.constant.AllConstants;
import com.gs.SynAntiWandering.util.SPUtil;

public class LanguageDialog extends BaseDialog {

    public LanguageDialog(@NonNull Context context, IDoneListener iDoneListener) {
        super(context, R.style.toast_dialog);
        this.iDoneListener = iDoneListener;
    }

    @Override
    public void refreshView() {

    }

    @Override
    public void initView() {
        RadioGroup rg = findViewById(R.id.rg_language);
        int language = SPUtil.getInstance().getInt(AllConstants.LANGUAGE, 1);
        rg.check(language == 1 ? R.id.rb_chinese : R.id.rb_english);
        rg.setOnCheckedChangeListener((group, checkedId) -> {
            iDoneListener.getDoneFromDialog(checkedId);
            dismiss();
        });
    }

    @Override
    public int getLayoutId() {
        return R.layout.dialog_language;
    }

    private final IDoneListener iDoneListener;

    public interface IDoneListener {
        void getDoneFromDialog(int checkedId);
    }
}
